package com.hundun.hddeal.service.lmpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hundun.hddeal.dao.InvoiceMapper;
import com.hundun.hddeal.entity.Invoice;
import com.hundun.hddeal.response.Result;
import com.hundun.hddeal.response.ResultUtil;
import com.hundun.hddeal.service.InvoiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 发票业务层
 * @author 谢
 */
@Service
public class InvoiceServiceImpl implements InvoiceService {

    @Autowired
    InvoiceMapper invoiceMapper;

    @Override
    public Result deleteByPrimaryKey(Long id) {
        return null;
    }

    @Override
    public Result insertSelective(Invoice record) {
        try{
            invoiceMapper.insertSelective(record);
            return ResultUtil.success();
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.error();
        }
    }

    @Override
    public PageInfo<Invoice> selectAll(Integer page,Integer size) {
        PageHelper.startPage(page, size);
        List<Invoice> gzhList = invoiceMapper.selectAll();
        PageInfo<Invoice> pageInfo = new PageInfo<>(gzhList);
        return pageInfo;
    }

    @Override
    public Result updateByPrimaryKeySelective(Invoice record) {
        try{
            invoiceMapper.updateByPrimaryKeySelective(record);
            return ResultUtil.success();
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.error();
        }
    }


    @Override
    public Result<List<Invoice>> selectGetuser(String mtId) {
        try{
            List<Invoice> list=invoiceMapper.selectGetuser(mtId);
            return ResultUtil.success(list);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.error();
        }

    }
}
